package com.xiaoyu.izf.model;

import cn.hutool.core.date.DateUtil;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Objects;

@Entity
@Table(name = "commission_get_log", schema = "izf", catalog = "")
public class CommissionGetLog {
    private int id;
    private Integer totAmount;
    private Integer uid;
    private Integer payStatus;
    private Timestamp logTime;

    private String logTimeStr;
    private String bankName;
    private String bankBranchName;
    private String userName;
    private String bankAccount;
    private Integer handFee;
    private Integer totAmountTrue;

    private UserInfo user;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Basic
    @Column(name = "tot_amount")
    public Integer getTotAmount() {
        return totAmount;
    }

    public void setTotAmount(Integer totAmount) {
        this.totAmount = totAmount;
    }

    @Basic
    @Column(name = "uid")
    public Integer getUid() {
        return uid;
    }

    public void setUid(Integer uid) {
        this.uid = uid;
    }

    @Basic
    @Column(name = "pay_status")
    public Integer getPayStatus() {
        return payStatus;
    }

    public void setPayStatus(Integer payStatus) {
        this.payStatus = payStatus;
    }

    @Basic
    @Column(name = "log_time")
    public Timestamp getLogTime() {
        return logTime;
    }

    public void setLogTime(Timestamp logTime) {
        this.logTime = logTime;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        CommissionGetLog that = (CommissionGetLog) o;
        return id == that.id &&
                Objects.equals(totAmount, that.totAmount) &&
                Objects.equals(uid, that.uid) &&
                Objects.equals(payStatus, that.payStatus) &&
                Objects.equals(logTime, that.logTime);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, totAmount, uid, payStatus, logTime);
    }

    @Transient
    public String getLogTimeStr() {
        return DateUtil.date(logTime).toString();
    }

    @Basic
    @Column(name = "bank_name")
    public String getBankName() {
        return bankName;
    }

    public void setBankName(String bankName) {
        this.bankName = bankName;
    }

    @Basic
    @Column(name = "bank_branch_name")
    public String getBankBranchName() {
        return bankBranchName;
    }

    public void setBankBranchName(String bankBranchName) {
        this.bankBranchName = bankBranchName;
    }

    @Basic
    @Column(name = "user_name")
    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    @Basic
    @Column(name = "bank_account")
    public String getBankAccount() {
        return bankAccount;
    }

    public void setBankAccount(String bankAccount) {
        this.bankAccount = bankAccount;
    }

    @Basic
    @Column(name = "hand_fee")
    public Integer getHandFee() {
        return handFee;
    }

    public void setHandFee(Integer handFee) {
        this.handFee = handFee;
    }

    @Basic
    @Column(name = "tot_amount_true")
    public Integer getTotAmountTrue() {
        return totAmountTrue;
    }

    public void setTotAmountTrue(Integer totAmountTrue) {
        this.totAmountTrue = totAmountTrue;
    }

    @ManyToOne(cascade = CascadeType.REFRESH, fetch = FetchType.LAZY, optional = true)
    @NotFound(action = NotFoundAction.IGNORE)
    @JoinColumn(name = "uid", referencedColumnName = "id", insertable = false, updatable = false,foreignKey = @ForeignKey(value = ConstraintMode.NO_CONSTRAINT))
    public UserInfo getUser() {
        return user;
    }
    public void setUser(UserInfo user) {
        this.user = user;
    }
}
